In [1]:
from __future__ import print_function, division

In [2]:
# This changes the current directory to the base saga directory - make sure to run this first!
# This is necessary to be able to import the py files and use the right directories,
# while keeping all the notebooks in their own directory.
import os
import sys
from time import time

if 'saga_base_dir' not in locals():
    saga_base_dir = os.path.abspath('..')
if saga_base_dir not in sys.path:
    os.chdir(saga_base_dir)

In [3]:
import targeting
import casjobs

import numpy as np

from scipy import interpolate

from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy import table
from astropy.table import Table
from astropy.io import fits

from astropy.utils.console import ProgressBar
from astropy.utils import data

from collections import Counter

In [4]:
%matplotlib inline
from matplotlib import style, pyplot as plt

plt.style.use('seaborn-deep')
plt.rcParams['image.cmap'] = 'viridis'
plt.rcParams['image.origin'] = 'lower'
plt.rcParams['figure.figsize'] = (14, 8)
plt.rcParams['axes.titlesize'] =  plt.rcParams['axes.labelsize'] = 16
plt.rcParams['xtick.labelsize'] =  plt.rcParams['ytick.labelsize'] = 14

In [5]:
from IPython import display

In [40]:
def make_cutout_comparison_table(dcat):
    """
    Produces a table comparing DECaLS and SDSS objects side-by-side
    
    `dcat` should be a *DECaLS* catalog, not SDSS
    """
    de_cutout_url = 'http://legacysurvey.org/viewer/jpeg-cutout/?ra={0.ra.deg}&dec={0.dec.deg}&layer=decals-dr3&pixscale=0.1&bands=grz'
    sd_cutout_url = 'http://legacysurvey.org/viewer/jpeg-cutout/?ra={0.ra.deg}&dec={0.dec.deg}&layer=sdssco&pixscale=0.1&bands=gri'

    print('put this into http://skyserver.sdss.org/dr13/en/tools/chart/listinfo.aspx')
    print('name ra dec')

    tabrows = []
    for row in dcat:
        dviewurl = 'http://legacysurvey.org/viewer?ra={}&dec={}'.format(row['ra'], row['dec'])
        sviewurl = 'http://skyserver.sdss.org/dr12/en/tools/chart/navi.aspx?ra={}&dec={}'.format(row['ra'], row['dec'])
        sc = SkyCoord(row['ra'], row['dec'], unit=u.deg)
        objstr = '{}_{}<br>RA={:.4f}<br>Dec={:.4f}<br>r={:.2f}<br>sb={:.2f}'.format(row['brickid'], row['objid'], row['ra'], row['dec'], row['r'], row['sb_r_0.5'])
        deimg = '<a href="{}"><img src="{}"></a>'.format(dviewurl, de_cutout_url.format(sc))
        sdimg = '<a href="{}"><img src="{}"></a>'.format(sviewurl, sd_cutout_url.format(sc))
        tabrows.append('<tr><td>{}</td><td>{}</td><td>{}</td></tr>'.format(objstr, deimg, sdimg))
        print(row['brickname']+'_'+str(row['objid']), row['ra'], row['dec'])

    htmlstr = """
    <table>

    <tr>
    <th>obj</th>
    <th>DECALS</th>
    <th>SDSS</th>
    </tr>

    {}
    </table>
    """.format('\n'.join(tabrows))
    
    return display.HTML(htmlstr)

In [6]:
# from the DECALS low-SB_brick selection and data download notebook
bricknames = ['1181m012', '2208m005']

For more in-depth on the context for these, see DECALS low-SB_catalog completeness.ipynb

Load the catalogs


In [7]:
catalog_fns = ['decals_dr3/catalogs/tractor-{}.fits'.format(bnm) for bnm in bricknames]
decals_catalogs = [Table.read(fn) for fn in catalog_fns]


WARNING: UnitsWarning: '1/deg^2' did not parse as fits unit: Numeric factor not supported by FITS [astropy.units.core]
WARNING:astropy:UnitsWarning: '1/deg^2' did not parse as fits unit: Numeric factor not supported by FITS
WARNING: UnitsWarning: 'nanomaggy' did not parse as fits unit: At col 0, Unit 'nanomaggy' not supported by the FITS standard.  [astropy.units.core]
WARNING:astropy:UnitsWarning: 'nanomaggy' did not parse as fits unit: At col 0, Unit 'nanomaggy' not supported by the FITS standard. 
WARNING: UnitsWarning: '1/nanomaggy^2' did not parse as fits unit: Numeric factor not supported by FITS [astropy.units.core]
WARNING:astropy:UnitsWarning: '1/nanomaggy^2' did not parse as fits unit: Numeric factor not supported by FITS
WARNING: UnitsWarning: '1/arcsec^2' did not parse as fits unit: Numeric factor not supported by FITS [astropy.units.core]
WARNING:astropy:UnitsWarning: '1/arcsec^2' did not parse as fits unit: Numeric factor not supported by FITS

In [8]:
sdss_fns = ['decals_dr3/catalogs/sdss_comparison_{}.csv'.format(bnm) for bnm in bricknames]
sdss_catalogs = [Table.read(fn) for fn in sdss_fns]

In [9]:
bricks = Table.read('decals_dr3/survey-bricks.fits.gz')
bricksdr3 = Table.read('decals_dr3/survey-bricks-dr3.fits.gz')

Populate additional info in the DECaLS tables


In [10]:
ap_sizes = [0.5,0.75,1.0,1.5,2.0,3.5,5.0,7.0] * u.arcsec

In [11]:
def compute_sb(rad, apflux):
    if len(apflux.shape)==2:
        idxs = np.where(ap_sizes==rad)[0]
        assert len(idxs)==1, 'No aperture with size {}'.format(rad)
        
        apflux = apflux[:, idxs[0]]
    A = 2.5*np.log10(np.pi*(rad.to(u.arcsec).value)**2)
    return np.array(22.5 - 2.5*np.log10(apflux) + A) * u.mag * u.arcsec**-2
        
for dcat in decals_catalogs:
    dcat['g'] = np.array(22.5 - 2.5*np.log10(dcat['decam_flux'][:, 1]))*u.mag
    dcat['r'] = np.array(22.5 - 2.5*np.log10(dcat['decam_flux'][:, 2]))*u.mag
    dcat['z'] = np.array(22.5 - 2.5*np.log10(dcat['decam_flux'][:, 4]))*u.mag
    
    dcat['sb_r_0.5'] = compute_sb(0.5*u.arcsec, dcat['decam_apflux'][:, 2, :])
    dcat['sb_r_0.75'] = compute_sb(0.75*u.arcsec, dcat['decam_apflux'][:, 2, :])
    dcat['sb_r_1'] = compute_sb(1.0*u.arcsec, dcat['decam_apflux'][:, 2, :])
    dcat['sb_r_2'] =compute_sb(2.0*u.arcsec, dcat['decam_apflux'][:, 2, :])


/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:11: RuntimeWarning: divide by zero encountered in log10
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:11: RuntimeWarning: invalid value encountered in log10
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:12: RuntimeWarning: divide by zero encountered in log10
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:12: RuntimeWarning: invalid value encountered in log10
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:13: RuntimeWarning: divide by zero encountered in log10
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:13: RuntimeWarning: invalid value encountered in log10
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: divide by zero encountered in log10
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in log10

Compute SDSS-like SB's

We want to try to get a surface birghtness something like SDSS's expmag + 2.5 log10(2 pi exprad^2). But DECaLS has no expmag. So lets try interpolating the aperture fluxes to the appropriate radius.


In [12]:
dcat0 = decals_catalogs[0]
rap_fluxes = dcat0['decam_apflux'][:, 2, :]

expfluxr = np.empty_like(rap_fluxes[:, 0])
ap_sizesv = ap_sizes.to(u.arcsec).value
for i in ProgressBar(range(len(rap_fluxes)), ipython_widget=True):
    f = rap_fluxes[i]
    r = dcat0['shapeExp_r'][i]
    expfluxr[i] = np.interp(r, ap_sizesv, f)



Now lets visualize a few of these flux profiles just to see if this seems sensible


In [13]:
j = 0
for i in np.random.permutation(len(rap_fluxes)):
    fnorm = rap_fluxes[i][4]
    p = plt.plot(ap_sizes, rap_fluxes[i]/fnorm,'-o', ms=4, mew=0)[0]
    plt.scatter([dcat0['shapeExp_r'][i]], [expfluxr[i]/fnorm], color=p.get_color(), s=60, zorder=5)
    j += 1
    if j>9:
        break

plt.xlim(0, 7)
plt.ylim(0, 2)
plt.xlabel('aperture')
plt.ylabel('flux w/i aperture, normalized to 2"')


Out[13]:
<matplotlib.text.Text at 0x116dc4490>

What's the deal with all those objects that have an shapeExp_r of 0?


In [14]:
Counter(dcat0[dcat0['shapeExp_r']>0]['type']), Counter(dcat0[dcat0['shapeExp_r']==0]['type'])


Out[14]:
(Counter({'COMP': 34, 'EXP ': 1113, 'SIMP': 696}),
 Counter({'DEV ': 243, 'PSF ': 6437}))

Oops... looks like stars, and more importantly, DeV-fit galaxies, have no shapeExp_r! Guess we have to use other shapes for them. So we'll use decam_psfsize for the stars, shapeDev_r for the early-types, and shapeExp_r for other gals.


In [15]:
dcat0 = decals_catalogs[0]
rap_fluxes = dcat0['decam_apflux'][:, 2, :]

fluxr = np.empty_like(rap_fluxes[:, 0])
rap_sizesv = ap_sizes.to(u.arcsec).value

intr = interpolate.BarycentricInterpolator(ap_sizesv, [0]*len(ap_sizesv))
for i in ProgressBar(range(len(rap_fluxes)), ipython_widget=True):
    f = rap_fluxes[i]
    if dcat0['type'][i] == 'PSF ':
        r = dcat0['decam_psfsize'][i, 2]
    elif dcat0['type'][i] == 'DEV ':
        r = dcat0['shapeDev_r'][i]
    else:
        r = dcat0['shapeExp_r'][i]
        
    intr.set_yi(f)
    fluxr[i] = intr(r)




In [16]:
fig, (ax1, ax2) = plt.subplots(1, 2)

rs = []
fluxes = []
colors = []
markers = []
for i in np.random.permutation(len(rap_fluxes))[:15]:
    fnorm = rap_fluxes[i][4]
    p = ax1.plot(ap_sizes, rap_fluxes[i]/fnorm,'-o', ms=4, mew=0)[0]
    colors.append(p.get_color())
    if dcat0['type'][i] == 'PSF ':
        rs.append(dcat0['decam_psfsize'][i, 2])
        markers.append('*')
    elif dcat0['type'][i] == 'DEV ':
        rs.append(dcat0['shapeDev_r'][i])
        markers.append('^')
    else:
        rs.append(dcat0['shapeExp_r'][i])
        markers.append('o')
    fluxes.append(fluxr[i])
    
    ax1.scatter([rs[-1]], [fluxr[i]/fnorm], color=colors[-1], 
                s=60 if markers[-1]=='o' else 80,
                zorder=5, marker=markers[-1])
    
#     #uncomment this to look at the total flux of a star
#     if markers[-1]=='*':
#         ax1.scatter([rs[-1]], [dcat0['decam_flux'][i, 2]/fnorm], color=colors[-1], 
#                     s=60 if markers[-1]=='o' else 80,
#                     zorder=5, marker='s')
        
ax1.set_xlim(0, 7)
ax1.set_ylim(0, 2)
ax1.set_xlabel('aperture')
ax1.set_ylabel('flux w/i aperture, normalized to 2"')

sb = compute_sb(rs*u.arcsec, np.array(fluxes))
mags = np.array(22.5 - 2.5*np.log10(fluxes))
for x, y, c, m in zip(mags, sb, colors, markers):
    ax2.scatter([x], [y.value], color=c, 
                s=60 if m=='o' else 80,
                zorder=5, marker=m)
ax2.set_xlabel('$r$')
ax2.set_ylabel('SDSS-like SB')
    
print('triangles are DeV, circles are exp, * are PSFs')


triangles are DeV, circles are exp, * are PSFs

In [17]:
for dcat in decals_catalogs:
    rap_fluxes = dcat['decam_apflux'][:, 2, :]

    expflux_r = np.empty_like(rap_fluxes[:, 0])
    rad = np.empty(len(rap_fluxes[:, 0]))
    ap_sizesv = ap_sizes.to(u.arcsec).value

    intr = interpolate.BarycentricInterpolator(ap_sizesv, [0]*len(ap_sizesv))
    for i in ProgressBar(range(len(rap_fluxes)), ipython_widget=True):
        f = rap_fluxes[i]
        if dcat['type'][i] == 'PSF ':
            r = dcat['decam_psfsize'][i, 2]
        elif dcat['type'][i] == 'DEV ':
            r = dcat['shapeDev_r'][i]
        else:
            r = dcat['shapeExp_r'][i]

        intr.set_yi(f)
        expflux_r[i] = intr(r)
        rad[i] = r
        
    dcat['sdss_like_sb_r'] = compute_sb(rad*u.arcsec, np.array(expflux_r))



/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:7: RuntimeWarning: divide by zero encountered in log10
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: divide by zero encountered in log10
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in log10
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in add

Cut out areas of overlap from the bricks, and then combine them


In [18]:
boundaries = [((-1.375, -1.2), (118, 118.145)),
              ((-0.625, -0.375), (220.75, 221))]

In [19]:
dcut = []
scut = []

In [20]:
dcat = decals_catalogs[0]
scat = sdss_catalogs[0]
bnds = boundaries[0]

plt.scatter(dcat['ra'], dcat['dec'], lw=0, c='g')
plt.scatter(scat['RA'], scat['DEC'], lw=0, c='r')

plt.axhline(bnds[0][0], c='k', ls='--')
plt.axhline(bnds[0][1], c='k', ls='--')
plt.axvline(bnds[1][0], c='k', ls='--')
plt.axvline(bnds[1][1], c='k', ls='--')

dmsk = ((bnds[1][0]<dcat['ra']) & (dcat['ra']<bnds[1][1]) &
        (bnds[0][0]<dcat['dec']) & (dcat['dec']<bnds[0][1]))
dcut.append(dcat[dmsk])


smsk = ((bnds[1][0]<scat['RA']) & (scat['RA']<bnds[1][1]) &
        (bnds[0][0]<scat['DEC']) & (scat['DEC']<bnds[0][1]))
scut.append(scat[smsk])



In [21]:
dcat = decals_catalogs[1]
scat = sdss_catalogs[1]
bnds = boundaries[1]

plt.scatter(dcat['ra'], dcat['dec'], lw=0, c='g')
plt.scatter(scat['RA'], scat['DEC'], lw=0, c='r')

plt.axhline(bnds[0][0], c='k', ls='--')
plt.axhline(bnds[0][1], c='k', ls='--')
plt.axvline(bnds[1][0], c='k', ls='--')
plt.axvline(bnds[1][1], c='k', ls='--')

dmsk = ((bnds[1][0]<dcat['ra']) & (dcat['ra']<bnds[1][1]) &
        (bnds[0][0]<dcat['dec']) & (dcat['dec']<bnds[0][1]))
dcut.append(dcat[dmsk])


smsk = ((bnds[1][0]<scat['RA']) & (scat['RA']<bnds[1][1]) &
        (bnds[0][0]<scat['DEC']) & (scat['DEC']<bnds[0][1]))
scut.append(scat[smsk])



In [22]:
dcutall = table.vstack(dcut)
scutall = table.vstack(scut)

X-matching catalogs


In [23]:
dsc = SkyCoord(dcutall['ra'], dcutall['dec'], unit=u.deg)
ssc = SkyCoord(scutall['RA'], scutall['DEC'], unit=u.deg)

In [24]:
idx, d2d, _ = ssc.match_to_catalog_sky(dsc)
plt.hist(d2d.arcsec, bins=100, range=(0, 3),histtype='step', log=True)
None



In [25]:
dmatchmsk = idx[d2d<1.5*u.arcsec]
dmatch = dcutall[dmatchmsk]

smatch = scutall[d2d<1.5*u.arcsec]

In [26]:
didxs = np.arange(len(dcutall))
dnomatchmsk = didxs[~np.in1d(didxs, idx[d2d<1.5*u.arcsec])]
dnomatch = dcutall[dnomatchmsk]

In [27]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sb_r_0.5'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
sstar = smatch['PHOT_SG']=='STAR'
plt.scatter(x[~dstar&~sstar], y[~dstar&~sstar], c='b', lw=0, alpha=.5, label='Glx in Both')
plt.scatter(x[dstar&~sstar], y[dstar&~sstar], c='r', lw=0, alpha=.5, label='Star in DECaLS, Glx in SDSS')
plt.scatter(x[~dstar&sstar], y[~dstar&sstar], c='g', lw=0, alpha=.5, label='Glx in DECaLS, Star in SDSS')

dnstar = dnomatch['type']=='PSF '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar], (dnomatch[ynm] - dnoext)[~dnstar], 
            c='k', lw=0, alpha=.5, label='Glx in DECALS, not in SDSS')

#plt.hlines(24.5, 17, 21, colors='k', linestyles='--')
plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 28)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{0.5^{\prime \prime}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)
plt.savefig(os.environ['HOME'] + '/Desktop/fig_decals.pdf')


Galaxies in DECaLS w/ low SB


In [41]:
to_check = (dcutall['r']<21)&(dcutall['sb_r_0.5']>24.5) & (dcutall['type']!='PSF ')
make_cutout_comparison_table(dcutall[to_check])


put this into http://skyserver.sdss.org/dr13/en/tools/chart/listinfo.aspx
name ra dec
1181m012_678 118.112199737 -1.36244765285
1181m012_993 118.073844294 -1.35064712055
1181m012_2942 118.093188198 -1.29399519212
1181m012_2945 118.087942554 -1.2876046284
2208m005_785 220.792331062 -0.597459136591
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:1: RuntimeWarning: invalid value encountered in less
  if __name__ == '__main__':
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:1: RuntimeWarning: invalid value encountered in greater
  if __name__ == '__main__':
Out[41]:
obj DECALS SDSS
323640_678
RA=118.1122
Dec=-1.3624
r=20.08
sb=27.24
323640_993
RA=118.0738
Dec=-1.3506
r=19.64
sb=26.22
323640_2942
RA=118.0932
Dec=-1.2940
r=19.75
sb=25.98
323640_2945
RA=118.0879
Dec=-1.2876
r=19.74
sb=26.97
328371_785
RA=220.7923
Dec=-0.5975
r=20.45
sb=25.81

All seem to be artifacts in DECaLS - scattered light, cosmic rays, etc

Galaxies in DECaLS, nothing in SDSS


In [42]:
to_check = ((18<dnomatch['r']) & (dnomatch['r']<21) &
            (18<dnomatch['sb_r_0.5']) & (dnomatch['sb_r_0.5']<24.5) & 
            (dnomatch['type']!='PSF '))
make_cutout_comparison_table(dnomatch[to_check])


put this into http://skyserver.sdss.org/dr13/en/tools/chart/listinfo.aspx
name ra dec
1181m012_961 118.121513445 -1.35257640112
1181m012_1384 118.038073493 -1.34092907625
1181m012_1656 118.090730955 -1.33314864522
1181m012_1800 118.117388763 -1.32869772927
1181m012_2014 118.083627175 -1.32579902208
1181m012_2700 118.112946373 -1.29868529355
1181m012_2876 118.031814095 -1.29029361373
1181m012_2878 118.030590431 -1.29002895308
1181m012_2880 118.028672101 -1.28997846323
1181m012_2912 118.003665054 -1.29901194917
1181m012_2935 118.087672265 -1.29341850195
1181m012_3798 118.088913439 -1.26723945505
1181m012_4682 118.087427046 -1.23734510488
1181m012_4685 118.088564737 -1.24490918031
1181m012_5813 118.090766692 -1.20919653906
2208m005_968 220.855751224 -0.592980315504
2208m005_2626 220.816086592 -0.533070890865
2208m005_4659 220.897160891 -0.458573580142
2208m005_6437 220.812481307 -0.398810751892
2208m005_6656 220.750771946 -0.386014017194
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:4: RuntimeWarning: invalid value encountered in greater
/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:4: RuntimeWarning: invalid value encountered in less
Out[42]:
obj DECALS SDSS
323640_961
RA=118.1215
Dec=-1.3526
r=20.60
sb=21.82
323640_1384
RA=118.0381
Dec=-1.3409
r=20.64
sb=20.31
323640_1656
RA=118.0907
Dec=-1.3331
r=19.85
sb=22.16
323640_1800
RA=118.1174
Dec=-1.3287
r=19.66
sb=20.41
323640_2014
RA=118.0836
Dec=-1.3258
r=20.05
sb=21.52
323640_2700
RA=118.1129
Dec=-1.2987
r=20.40
sb=22.49
323640_2876
RA=118.0318
Dec=-1.2903
r=20.68
sb=22.43
323640_2878
RA=118.0306
Dec=-1.2900
r=20.69
sb=21.28
323640_2880
RA=118.0287
Dec=-1.2900
r=20.70
sb=21.98
323640_2912
RA=118.0037
Dec=-1.2990
r=20.64
sb=23.44
323640_2935
RA=118.0877
Dec=-1.2934
r=18.64
sb=20.21
323640_3798
RA=118.0889
Dec=-1.2672
r=20.57
sb=22.22
323640_4682
RA=118.0874
Dec=-1.2373
r=19.92
sb=21.27
323640_4685
RA=118.0886
Dec=-1.2449
r=20.99
sb=22.73
323640_5813
RA=118.0908
Dec=-1.2092
r=20.98
sb=22.19
328371_968
RA=220.8558
Dec=-0.5930
r=20.30
sb=22.68
328371_2626
RA=220.8161
Dec=-0.5331
r=18.33
sb=23.11
328371_4659
RA=220.8972
Dec=-0.4586
r=20.73
sb=22.20
328371_6437
RA=220.8125
Dec=-0.3988
r=20.93
sb=18.07
328371_6656
RA=220.7508
Dec=-0.3860
r=19.62
sb=23.21

These are almost entirely either deblender ambiguities (i.e. by eye may or may not be two sources) or areas where SDSS had a scattered-light/background problem. A few debatebly real objects, but not preferentially low-SB or anything.

Gals in DECaLS, stars in SDSS


In [46]:
to_check = ~dstar&sstar&(dmatch['r']<21)
make_cutout_comparison_table(dmatch[to_check])


put this into http://skyserver.sdss.org/dr13/en/tools/chart/listinfo.aspx
name ra dec
1181m012_4370 118.00903537 -1.25056657662
1181m012_5940 118.00881619 -1.20212316278
1181m012_5564 118.057734628 -1.21970565011
1181m012_49 118.122769028 -1.37418441193
1181m012_5499 118.001479221 -1.2214788251
1181m012_408 118.023907004 -1.36462119026
1181m012_994 118.075494053 -1.35493962314
1181m012_5371 118.122140921 -1.21010441942
1181m012_5341 118.121170142 -1.21261239748
1181m012_1509 118.050831575 -1.32103677862
1181m012_991 118.076940742 -1.3517534848
1181m012_4088 118.140225545 -1.25900783411
1181m012_3108 118.06608604 -1.29011770684
1181m012_2358 118.136238488 -1.31197729034
1181m012_2052 118.067539464 -1.32199988816
1181m012_2932 118.09147149 -1.29033801472
2208m005_2546 220.923439054 -0.531831133477
2208m005_1496 220.946007697 -0.568820576871
2208m005_1958 220.951999097 -0.561450444598
2208m005_1493 220.938821057 -0.564776676641
2208m005_1491 220.944180245 -0.57134820099
2208m005_4522 220.90449673 -0.466506285514
2208m005_5383 220.804961066 -0.437056617797
2208m005_2173 220.837209045 -0.550249082603
Out[46]:
obj DECALS SDSS
323640_4370
RA=118.0090
Dec=-1.2506
r=18.54
sb=19.94
323640_5940
RA=118.0088
Dec=-1.2021
r=20.12
sb=21.21
323640_5564
RA=118.0577
Dec=-1.2197
r=20.37
sb=23.47
323640_49
RA=118.1228
Dec=-1.3742
r=12.09
sb=17.74
323640_5499
RA=118.0015
Dec=-1.2215
r=20.89
sb=22.14
323640_408
RA=118.0239
Dec=-1.3646
r=20.48
sb=21.60
323640_994
RA=118.0755
Dec=-1.3549
r=20.22
sb=24.34
323640_5371
RA=118.1221
Dec=-1.2101
r=19.65
sb=20.98
323640_5341
RA=118.1212
Dec=-1.2126
r=9.92
sb=17.07
323640_1509
RA=118.0508
Dec=-1.3210
r=12.14
sb=17.51
323640_991
RA=118.0769
Dec=-1.3518
r=12.35
sb=17.67
323640_4088
RA=118.1402
Dec=-1.2590
r=15.19
sb=16.27
323640_3108
RA=118.0661
Dec=-1.2901
r=18.12
sb=19.26
323640_2358
RA=118.1362
Dec=-1.3120
r=20.31
sb=21.48
323640_2052
RA=118.0675
Dec=-1.3220
r=19.74
sb=20.82
323640_2932
RA=118.0915
Dec=-1.2903
r=12.19
sb=17.29
328371_2546
RA=220.9234
Dec=-0.5318
r=11.21
sb=16.41
328371_1496
RA=220.9460
Dec=-0.5688
r=19.53
sb=23.06
328371_1958
RA=220.9520
Dec=-0.5615
r=20.45
sb=22.13
328371_1493
RA=220.9388
Dec=-0.5648
r=12.25
sb=16.33
328371_1491
RA=220.9442
Dec=-0.5713
r=12.92
sb=16.08
328371_4522
RA=220.9045
Dec=-0.4665
r=20.89
sb=22.19
328371_5383
RA=220.8050
Dec=-0.4371
r=20.45
sb=21.38
328371_2173
RA=220.8372
Dec=-0.5502
r=13.73
sb=17.11

A few are possibly real due to improved seeing (323640_5940, 323640_5564), vast majority are either areas where SDSS backgrounds are problematic, or bright star artifacts/blended stars.

Try with other aperture sizes

This also has a few more points for stars just to see the differences. That's why we still include 0.5 even though it's above, too

0.5"


In [30]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sb_r_0.5'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
sstar = smatch['PHOT_SG']=='STAR'


dnstar = dnomatch['type']=='PSF '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar], (dnomatch[ynm] - dnoext)[~dnstar], 
            c='k', lw=0, alpha=.5, label='Glx in DECALS, not in SDSS', marker='s')
plt.scatter((dnomatch[xnm] - dnoext)[dnstar], (dnomatch[ynm] - dnoext)[dnstar], 
            c='k', lw=0, alpha=.3, s=60, 
            label='Star in DECALS, not in SDSS', marker='*')

plt.scatter(x[dstar&sstar], y[dstar&sstar], c='m', lw=0, alpha=.5, s=60,
            label='Star in both', marker='*')

plt.scatter(x[~dstar&~sstar], y[~dstar&~sstar], c='b', lw=0, alpha=.5, label='Glx in Both')
plt.scatter(x[dstar&~sstar], y[dstar&~sstar], c='r', lw=0, alpha=.5, 
            label='Star in DECaLS, Glx in SDSS', marker='^', s=50)
plt.scatter(x[~dstar&sstar], y[~dstar&sstar], c='g', lw=0, alpha=.5, 
            label='Glx in DECaLS, Star in SDSS', marker='^', s=50)


#plt.hlines(24.5, 17, 21, colors='k', linestyles='--')
plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 28)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{0.5^{\prime \prime}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)


Out[30]:
<matplotlib.legend.Legend at 0x11877cc90>

0.75"


In [31]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sb_r_0.75'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
sstar = smatch['PHOT_SG']=='STAR'


dnstar = dnomatch['type']=='PSF '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar], (dnomatch[ynm] - dnoext)[~dnstar], 
            c='k', lw=0, alpha=.5, label='Glx in DECALS, not in SDSS', marker='s')
plt.scatter((dnomatch[xnm] - dnoext)[dnstar], (dnomatch[ynm] - dnoext)[dnstar], 
            c='k', lw=0, alpha=.3, s=60, 
            label='Star in DECALS, not in SDSS', marker='*')

plt.scatter(x[dstar&sstar], y[dstar&sstar], c='m', lw=0, alpha=.5, s=60,
            label='Star in both', marker='*')

plt.scatter(x[~dstar&~sstar], y[~dstar&~sstar], c='b', lw=0, alpha=.5, label='Glx in Both')
plt.scatter(x[dstar&~sstar], y[dstar&~sstar], c='r', lw=0, alpha=.5, 
            label='Star in DECaLS, Glx in SDSS', marker='^', s=50)
plt.scatter(x[~dstar&sstar], y[~dstar&sstar], c='g', lw=0, alpha=.5, 
            label='Glx in DECaLS, Star in SDSS', marker='^', s=50)



#plt.hlines(24.5, 17, 21, colors='k', linestyles='--')
plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 28)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{0.75^{\prime \prime}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)


Out[31]:
<matplotlib.legend.Legend at 0x11f3ee990>

1.0"


In [32]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sb_r_1'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
sstar = smatch['PHOT_SG']=='STAR'


dnstar = dnomatch['type']=='PSF '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar], (dnomatch[ynm] - dnoext)[~dnstar], 
            c='k', lw=0, alpha=.5, label='Glx in DECALS, not in SDSS', marker='s')
plt.scatter((dnomatch[xnm] - dnoext)[dnstar], (dnomatch[ynm] - dnoext)[dnstar], 
            c='k', lw=0, alpha=.3, s=60, 
            label='Star in DECALS, not in SDSS', marker='*')

plt.scatter(x[dstar&sstar], y[dstar&sstar], c='m', lw=0, alpha=.5, s=60,
            label='Star in both', marker='*')

plt.scatter(x[~dstar&~sstar], y[~dstar&~sstar], c='b', lw=0, alpha=.5, label='Glx in Both')
plt.scatter(x[dstar&~sstar], y[dstar&~sstar], c='r', lw=0, alpha=.5, 
            label='Star in DECaLS, Glx in SDSS', marker='^', s=50)
plt.scatter(x[~dstar&sstar], y[~dstar&sstar], c='g', lw=0, alpha=.5, 
            label='Glx in DECaLS, Star in SDSS', marker='^', s=50)


#plt.hlines(24.5, 17, 21, colors='k', linestyles='--')
plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 28)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{1.0^{\prime \prime}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)


Out[32]:
<matplotlib.legend.Legend at 0x11c6c7790>

2.0"


In [33]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sb_r_2'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
sstar = smatch['PHOT_SG']=='STAR'


dnstar = dnomatch['type']=='PSF '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar], (dnomatch[ynm] - dnoext)[~dnstar], 
            c='k', lw=0, alpha=.5, label='Glx in DECALS, not in SDSS', marker='s')
plt.scatter((dnomatch[xnm] - dnoext)[dnstar], (dnomatch[ynm] - dnoext)[dnstar], 
            c='k', lw=0, alpha=.3, s=60, 
            label='Star in DECALS, not in SDSS', marker='*')

plt.scatter(x[dstar&sstar], y[dstar&sstar], c='m', lw=0, alpha=.5, s=60,
            label='Star in both', marker='*')

plt.scatter(x[~dstar&~sstar], y[~dstar&~sstar], c='b', lw=0, alpha=.5, label='Glx in Both')
plt.scatter(x[dstar&~sstar], y[dstar&~sstar], c='r', lw=0, alpha=.5, 
            label='Star in DECaLS, Glx in SDSS', marker='^', s=50)
plt.scatter(x[~dstar&sstar], y[~dstar&sstar], c='g', lw=0, alpha=.5, 
            label='Glx in DECaLS, Star in SDSS', marker='^', s=50)


#plt.hlines(24.5, 17, 21, colors='k', linestyles='--')
plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 28)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{2.0^{\prime \prime}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)


Out[33]:
<matplotlib.legend.Legend at 0x1200a41d0>

Interpolated SDSS-like SB

Important thing to understand here: this is not the same as the SDSS SB's for a subtle reason. The SDSS SB's are all from assuming an exponential profile. Here, instead (because DECaLS doesn't have the data for exp profiles if the object is not found to be exp type), we use an SB within either the exponential half-light radius, the de Vaucouleurs effective radius, or the seeing FWHM for exp galaxies, DeV galaxies, or PSF's, respectively.

The flux is also not the modeled flux, but rather an interpolated flux at that radius from the apertures.


In [34]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sdss_like_sb_r'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
sstar = smatch['PHOT_SG']=='STAR'


dnstar = dnomatch['type']=='PSF '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar], (dnomatch[ynm] - dnoext)[~dnstar], 
            c='k', lw=0, alpha=.5, label='Glx in DECALS, not in SDSS', marker='s')
plt.scatter((dnomatch[xnm] - dnoext)[dnstar], (dnomatch[ynm] - dnoext)[dnstar], 
            c='k', lw=0, alpha=.3, s=60, 
            label='Star in DECALS, not in SDSS', marker='*')

plt.scatter(x[dstar&sstar], y[dstar&sstar], c='m', lw=0, alpha=.5, s=60,
            label='Star in both', marker='*')

plt.scatter(x[~dstar&~sstar], y[~dstar&~sstar], c='b', lw=0, alpha=.5, label='Glx in Both')
plt.scatter(x[dstar&~sstar], y[dstar&~sstar], c='r', lw=0, alpha=.5, 
            label='Star in DECaLS, Glx in SDSS', marker='^', s=50)
plt.scatter(x[~dstar&sstar], y[~dstar&sstar], c='g', lw=0, alpha=.5, 
            label='Glx in DECaLS, Star in SDSS', marker='^', s=50)




#plt.hlines(24.5, 17, 21, colors='k', linestyles='--')
plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 30)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{sdssish}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)


Out[34]:
<matplotlib.legend.Legend at 0x12008d250>

The below plot is to see if there's significant differences between the two galaxy types, since their SB calculations are quite different


In [35]:
plt.figure(figsize=(12, 10))

xnm = 'r'
ynm = 'sdss_like_sb_r'

dmextinction = -2.5*np.log10(dmatch['decam_mw_transmission'][:, 2])
x = dmatch[xnm] - dmextinction
y = dmatch[ynm] - dmextinction
dstar = dmatch['type']=='PSF '
ddev = dmatch['type']=='DEV '
sstar = smatch['PHOT_SG']=='STAR'


dnstar = dnomatch['type']=='PSF '
dndev = dnomatch['type']=='DEV '
dnoext = -2.5*np.log10(dnomatch['decam_mw_transmission'][:, 2])

plt.scatter((dnomatch[xnm] - dnoext)[~dnstar&~dndev], (dnomatch[ynm] - dnoext)[~dnstar&~dndev], 
            c='g', lw=0, alpha=.5, label='Exp Glx in DECALS, not in SDSS', marker='*', s=40)
plt.scatter((dnomatch[xnm] - dnoext)[~dnstar&dndev], (dnomatch[ynm] - dnoext)[~dnstar&dndev], 
            c='k', lw=0, alpha=.5, label='DeV Glx in DECALS, not in SDSS', marker='^', s=30)

plt.scatter(x[~dstar&ddev], y[~dstar&ddev], c='b', lw=0, alpha=.5, 
            label='Exp Glx in DECaLS, in SDSS', marker='o', s=15)
plt.scatter(x[~dstar&~ddev], y[~dstar&~ddev], c='r', lw=0, alpha=.5, 
            label='DeV Glx in DECaLS, in SDSS', marker='s', s=20)




#plt.hlines(24.5, 17, 21, colors='k', linestyles='--')
plt.axvline(20.75, color='k', ls=':')

plt.xlim(17, 24.5)
plt.ylim(18, 30)

plt.xlabel(r'$r_{0, {\rm DECaLS}}$', fontsize=28)
plt.ylabel(r'$SB_{sdssish}, {\rm DECaLS}}$', fontsize=28)
plt.xticks(fontsize=24)
plt.yticks(fontsize=24)

plt.legend(loc='lower right', fontsize=20)


Out[35]:
<matplotlib.legend.Legend at 0x1205f8750>

Galaxy detection depth


In [36]:
maggaldepth = -2.5*(np.log10(5*dmatch['decam_galdepth']**-0.5)-9)
maggaldepthr = maggaldepth[:, 2]


/Users/erik/miniconda3/envs/saga/lib/python2.7/site-packages/ipykernel/__main__.py:1: RuntimeWarning: divide by zero encountered in power
  if __name__ == '__main__':

In [37]:
plt.figure()
plt.hist(maggaldepthr[np.isfinite(maggaldepthr)], bins=100, histtype='step', log=False)
plt.xlabel('galdepth in $r$')
plt.ylabel('$n$')
plt.tight_layout()

plt.figure()
plt.hist(maggaldepthr[np.isfinite(maggaldepthr)], bins=100, histtype='step', log=True)
plt.xlabel('galdepth in $r$')
plt.ylabel('$n$')
plt.tight_layout()



In [38]:
for bnm in np.unique(dmatch['brickname']):
    inbrick = dmatch['brickname'] == bnm
    plt.hist(maggaldepthr[np.isfinite(maggaldepthr)&inbrick], bins=100, histtype='step', log=True, label='Brick '+bnm)
   
plt.xlabel('galdepth in $r$')
plt.ylabel('$n$')
plt.legend(loc=0)
plt.tight_layout()